{% extends "settings/base.html" %}

{% block container-right %}
    <form class="form-horizontal form" action="" method="post">
      <fieldset>
        <legend class="title">个人信息</legend>
        {% csrf_token %}
        {% comment %}
        <div class="control-group">
            <label for="id_imgurl" class="control-label">个人头像</label>
            <div class="controls avatar">
                <img src="https://gravatar.com/avatar/{{ userprofile.imgurl }}?s=50" alt="{{ user.username }}">
                <span>通过 <a target="_blank" href="http://cn.gravatar.com/">Gravatar</a> 修改个人头像</span>
            </div>
        </div>
        {% endcomment %}
        <div class="control-group">
            <label class="control-label">GitHub账户关联</label>
            <div class="controls">
            {% if thirdpartyUser %}
              <a target="_blank" href="https://github.com/{{ thirdpartyUser.tp_username }}/" class="label label-success"><i class="icon-ok"></i>已关联 ({{ thirdpartyUser.tp_username }})</a>
            {% else %}
            <a target="_blank" href="https://github.com/login/oauth/authorize?client_id=63bbd038b8591356a841&redirect_uri=https://gitshell.com/login/oauth/github/apply/" class="btn btn-danger"><i class="icon-github"></i>关联 GitHub 账户</a>
            {% endif %}
            </div>
        </div>
        <div class="control-group">
            <label for="id_tweet" class="control-label">* 签名</label>
            <div class="controls">
                {{ userprofileForm.tweet }}
            </div>
        </div>
        <div class="control-group">
            <label for="id_nickname" class="control-label">昵称</label>
            <div class="controls">
                {{ userprofileForm.nickname }}
            </div>
        </div>
        <div class="control-group">
            <label for="id_website" class="control-label">网站</label>
            <div class="controls">
                {{ userprofileForm.website }}
            </div>
        </div>
        <div class="control-group">
            <label for="id_company" class="control-label">公司</label>
            <div class="controls">
                {{ userprofileForm.company }}
            </div>
        </div>
        <div class="control-group">
            <label for="id_location" class="control-label">位置</label>
            <div class="controls">
                {{ userprofileForm.location }}
            </div>
        </div>
        <div class="control-group">
            <label for="id_resume" class="control-label">简历</label>
            <div class="controls">
                <div class="wmd-panel">
                    <div id="wmd-button-bar"></div>
                    {{ userprofileForm.resume }}
                </div>
                <div id="wmd-preview" class="wmd-panel wmd-preview"></div>
            </div>
        </div>
        {% if error %}
        <div class="alert">
            <a data-dismiss="alert" class="close">×</a>
            <strong>出错了！</strong> {{ error }}
        </div>
        {% endif %}
        <div class="control-group">
        <div class="controls">
            <button id="id_add_submit" class="btn" type="submit">保存</button>
        </div>
        </div>
      </fieldset>
    </form>
{% endblock %}

{% block js %}
<script src="/static/js/min/markdown.min.js?timestamp={{gitshell.timestamp}}"></script>
<script>
/*global jQuery, window */
$(function(){
    var profile_init = function() {
        $('.control-group input').addClass('input-xxlarge');
        $('.control-group textarea').addClass('input-xxlarge');
        $('#id_resume').addClass('wmd-input');
        $('#id_resume').attr('placeholder', '使用Markdown语法');
        $('#id_resume').attr("id","wmd-input");
        var converter = Markdown.getSanitizingConverter();
        var editor = new Markdown.Editor(converter);
        editor.run();
    };
    profile_init();
});
</script>
{% endblock %}

